home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / visulztn / saoimage / saoimage.lha / hfiles / define.h < prev    next >
C/C++ Source or Header  |  1990-05-02  |  2KB  |  62 lines

  1. #ifndef lint
  2. static char defineId[] = "%W%  %G%";
  3. #endif
  4.  
  5. /*
  6.  * Module:    Define.h
  7.  * Purpose:    Define commonly used constants and macros
  8.  */
  9.  
  10. #define YES    1
  11. #define UNKNOWN 0
  12. #define NO    -1
  13. #define DONT_CARE -2
  14. #define U_DONT_CARE 0xA0000000
  15.  
  16. #define SZ_FNAME 128
  17. #define SZ_LINE 256
  18.  
  19. #define SMALL_NUMBER 1.0E-30
  20. #define LARGE_NUMBER 1.0E30
  21.  
  22. /* we don't know if every math.h has a PI defined */
  23. #ifndef PI
  24. #define PI 3.14159265358979323846
  25. #endif
  26. #define TWO_PI 6.28318530717958647692
  27.  
  28. /* STRUCTURES AND DEFINITIONS USED BY MANY FILES */
  29. #define MIN(a,b) (((a) < (b)) ? (a) : (b))
  30. #define MAX(a,b) (((a) > (b)) ? (a) : (b))
  31. #define SQR(a) ((a) * (a))
  32. #define ABS(a) ((a) < 0 ? (-(a)) : (a))
  33.  
  34. /*
  35.  * Macro:    RND
  36.  * Purpose:    Round to nearest integer value, regardless of sign
  37.  */
  38. #define RND(a) (((a) < 0.0) ? ((int)((a) - 0.5)) : ((int)((a) + 0.5)))
  39.  
  40. /*
  41.  * Macro:    INTERP
  42.  * Purpose:    Given X along a straight line, interpolate to solve for Y
  43.  * Used by:    Color map routines
  44.  * Inputs:    a,b are X at each end,  e,f are Y at each end, x is given X
  45.  * Exception:    a must be <= b
  46.  * Exception:    x must be between a and b (inclusive)
  47.  * Exception:    All values should be floating point
  48.  * Method:    If x is same as a, return e, else do interpolation.
  49.  *        If (b-a)==0, then (x-a)==0, so zero-divide is avoided.
  50.  */
  51. #define INTERP(a,x,b,e,f) ((x-(a))<SMALL_NUMBER) ? (e):(((f-(e))*(x-(a))/(b-(a)))+e)
  52.  
  53. /*
  54.  * Macro:    INCSZ
  55.  * Purpose:    Determine the increment in Y per unit step in X
  56.  * Used by:    Color map routines
  57.  * Inputs:    a,b are X at each end, e,f are Y at each end, z = scale factor
  58.  * Note:    z is the scale factor for a,b (e.g. 0-1 -> 0-255, z=255)
  59.  * Exception:    a must be <= b
  60.  */
  61. #define INCSZ(a,b,e,f,z) ((b-(a))<SMALL_NUMBER) ? (0.0):((f-(e))/((b-(a))*z))
  62.